import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:quality_ticket/pojo/quality_model.dart';

import 'color.dart';


/*
*
* 作业票-----左右布局Item
*
*
* */

///作业票布局---展开、收起--Item
class QulityTitleItem extends StatelessWidget {
  const QulityTitleItem({Key key,this.titleLeft,this.isShow,this.onTap}) : super(key: key);
  final String titleLeft;
  final bool isShow;
  final  Function onTap;

  @override
  Widget build(BuildContext context) {
    return  GestureDetector(
      onTap:onTap,
      child: Container(
        margin: EdgeInsets.only(top: 16.h, bottom: 17.h),
        child: Row(
          children: <Widget>[
            Text(
              titleLeft,
              style: TextStyle(fontSize: 16.sp, color: AppColor.font_black),
            ),
            Spacer(),
            Text(
              isShow ? "展开" : "收起",
              style: TextStyle(fontSize: 14.sp, color: AppColor.font_grey),
            ),
            Container(
              child: !isShow
                  ? Icon(
                Icons.expand_less,
                color: AppColor.font_grey,
              )
                  : Icon(
                Icons.expand_more,
                color: AppColor.font_grey,
              ),
            ),
          ],
        ),
      ),
    );
  }
}

///作业票布局--Item
class QualityItem extends StatelessWidget {
  QualityItem({
    Key key,
    this.leftString,
    this.rightString,
    this.colors,
    this.pngUrl,
    this.fontSizes,
    this.isNextItem = true,
    this.onTap,
  }) : super(key: key);

  String leftString;
  String rightString;
  Color colors;
  String pngUrl;
  int fontSizes;
  bool isNextItem;
  Function onTap;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        height: 60.h,
        decoration: BoxDecoration(
          border: Border(
            top: BorderSide(
              width: 0.5.h,
              color: Color.fromRGBO(233, 233, 233, 1),
            ),
            bottom: BorderSide(
              width: 0.5.h,
              color: Color.fromRGBO(233, 233, 233, 1),
            ),
          ),
        ),
        child: Row(
          children: <Widget>[
            Text(
              leftString,
              style: TextStyle(fontSize: 14.sp, color: AppColor.font_black),
            ),
            Spacer(),
            pngUrl != null
                ? Image.asset(
              pngUrl,
              width: 24.w,
              height: 14.h,
            )
                : Container(),
            rightString != null
                ? Container(
              margin: EdgeInsets.only(left: 8.w),
              child: Text(
                rightString,
                style: TextStyle(
                    fontSize: fontSizes == null ? 14.sp : fontSizes.sp,
                    color: colors),
              ),
            )
                : Container(),
            //判断是否有下一项
            Offstage(
              offstage: isNextItem,
              child: Container(
                margin: EdgeInsets.only(left: 8.w),
                child: Icon(
                  Icons.arrow_forward_ios,
                  size: 12.h,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

///作业票布局---多选--Item
class QulityCheckedItem extends StatelessWidget {

   QulityCheckedItem({Key key,this.list,this.onChanged,this.index}) : super(key: key);
   List<OperatingConditionsModel> list=[];
   Function onChanged;
   int index;


  @override
  Widget build(BuildContext context) {
    return operationPrerequisitesItem(index);
  }

   ///作业必备条件-Item
   Widget operationPrerequisitesItem(int index) {
     String condition_val = list[index].condition_val;
     bool checkValue = list[index].checkValue;
     return Container(
       height: 60.h,
       decoration: BoxDecoration(
         border: Border(
           top: BorderSide(
             width: 0.5.h, //宽度
             color: index == 0
                 ? Color.fromRGBO(233, 233, 233, 0)
                 : Color.fromRGBO(233, 233, 233, 1), //边框颜色
           ),
         ),
       ),
       child: Row(
         children: <Widget>[
           Expanded(
             child: Container(
               child: Text(
                 '${index + 1}.$condition_val',
                 style: TextStyle(fontSize: 14.sp, color: AppColor.font_black),
               ),
             ),
           ),
           Checkbox(
             value: checkValue,
             onChanged:onChanged,
           ),
         ],
       ),
     );
   }
}
